﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta charset="utf-8">
    <meta name="keywords" content="教务系统|教务办事大厅">
    <meta name="description" content=" 教务系统|教务办事大厅">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="renderer" content="webkit|ie-comp|ie-stand" />
    <link rel="stylesheet" href="https://at.alicdn.com/t/font_533449_naak7odp5x.css" />
    <link rel="stylesheet" type="text/css" href="/ViewV5/CSS/bootstrap3.3.5/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="/ViewV5/CSS/default.css">
    <link rel="stylesheet" type="text/css" href="/ViewV5/CSS/index.css">
    <link href="/ViewV5/JS/element/index.css" rel="stylesheet" />

    <title></title>

    <style>
        .card {
            border: 1px solid #eee;
            -webkit-transition: all .5s ease-in-out;
            -moz-transition: all .2s ease-in-out;
            transition: all .2s ease-in-out;
            width: 140PX;
            padding: 15PX;
        }

            .card:hover {
                box-shadow: 0px 2px 8px #3252f1;
                cursor: pointer;
                -webkit-transition: all .5s ease-in-out;
                -moz-transition: all .2s ease-in-out;
                transition: all .2s ease-in-out;
            }

        h5 {
            FONT-WEIGHT: 700;
            MARGIN-TOP: 2PX;
        }

        img {
            border-radius: 50%;
        }

        .warning-row {
            BACKGROUND: #f87f7f !important;
            COLOR: #f1f1f1 !important;
        }

            .warning-row:hover {
                BACKGROUND: #f87f7f !important;
                COLOR: #f1f1f1 !important;
            }

            .warning-row > td {
                background-color: transparent !important;
            }

        .success-row {
            background: #4cff00 !important;
        }
    </style>
</head>
<body>
    <div class="work" id="WORK">
        <div class="main-content ft16 mt10  c666" style="min-height:550px;padding:20px; overflow: auto;">
            <div>

                <div class="input-group" style="margin-bottom:10PX;">
                    <div class="input-group-btn">
                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary  dropdown-toggle">导入学期</button>
                    </div>
                    <base-xq :pzoption="query.xq"></base-xq>

                </div>
            </div>
            <div class="mb20 progress-item">
                <p>
                    选择需要导入的Excel  <button type="button" class="btn btn-info btn-sm" @click="UploadClick()"><i class="iconfont icon-fj ft14 mr5"></i>添加附件</button>
                    <input type="file" name="upFile" id="upFile" class="form-control" @change="LoadUser()" accept=".xls,.xlsx" style="display:none;">
                    <a href="/upload/drmb/任务导入模板.xlsx" class="btn btn-warning btn-sm"><i class="iconfont icon-fj ft14 mr5"></i>下载导入模板</a>
                    <button type="button" class="btn btn-info btn-sm" style="margin-left:50PX" @click="CheckData()"><i class="iconfont icon-fj ft14 mr5"></i>检查数据</button>
                    <button type="button" class="btn btn-danger btn-sm" style="margin-left:50PX" @click="DRData()"><i class="iconfont icon-fj ft14 mr5"></i>导入数据</button>

                </p>
                <p style="margin-bottom:5px;" class="mt10">
                    <el-alert title="错误提示" v-show="ImportMsg"
                              type="error"
                              :description="ImportMsg"
                              show-icon>
                    </el-alert>
                </p>
                <pl-table :data="imPortData" :row-style="{height:'20px'}" :cell-style="{padding:'0px'}" style="font-size: 10px" height="450" :row-class-name="tableRowClassName" stripe border fit use-virtual big-data-checkbox>

                    <pl-table-column type="index" sortable
                                     width="50">
                    </pl-table-column>
                    <pl-table-column prop="班级" sortable
                                     label="班级" width="120">
                    </pl-table-column>
                    <pl-table-column prop="课程代码" sortable
                                     label="课程代码" width="150">
                    </pl-table-column>
                    <pl-table-column prop="课程名称" sortable
                                     label="课程名称" width="170">
                    </pl-table-column>
                    <!--<pl-table-column prop="考核" sortable width="80"
                                     label="考核">
                    </pl-table-column>-->
                    <pl-table-column prop="学时" sortable width="80"
                                     label="学时">
                    </pl-table-column>
                    <pl-table-column prop="学分" sortable width="80"
                                     label="学分">
                    </pl-table-column>
                    <pl-table-column prop="实践学时" sortable width="110"
                                     label="实践学时">
                    </pl-table-column>
                    <pl-table-column prop="上机周学时" sortable width="140"
                                     label="上机周学时">
                    </pl-table-column>
                    <pl-table-column prop="周学时" sortable width="110"
                                     label="周学时">
                        <template slot-scope="scope">
                            <el-input v-model="scope.row.周学时" placeholder="" size="mini" style="width:60PX"></el-input>
                        </template>
                    </pl-table-column>



                    <pl-table-column prop="起始周" sortable width="110"
                                     label="起始周">
                        <template slot-scope="scope">
                            <el-input v-model="scope.row.起始周" placeholder="" size="mini" style="width:60PX"></el-input>
                        </template>
                    </pl-table-column>
                    <pl-table-column prop="结束周" sortable width="110"
                                     label="结束周">
                        <template slot-scope="scope">
                            <el-input v-model="scope.row.结束周" placeholder="" size="mini" style="width:60PX"></el-input>
                        </template>
                    </pl-table-column>
                    <pl-table-column prop="上课教师" sortable width="120"
                                     label="上课教师">
                        <template slot-scope="scope">
                            <el-input v-model="scope.row.上课教师" placeholder="" size="mini" style="width:80PX"></el-input>
                        </template>
                    </pl-table-column>
                    <pl-table-column prop="合班班级" sortable width="120"
                                     label="合班班级">
                    </pl-table-column>
                    <pl-table-column prop="hbbh" sortable width="120"
                                     label="合班班号">
                    </pl-table-column>
                    <pl-table-column prop="导入状态" sortable width="120"
                                     label="导入状态">
                    </pl-table-column>
                    <pl-table-column prop="bh" sortable width="120"
                                     label="班号">
                    </pl-table-column>
                    <pl-table-column prop="jsdm" sortable width="120"
                                     label="教师代码">
                    </pl-table-column>
                </pl-table>
            </div>

        </div>
    </div>
    <script src="/ViewV5/JS/vue.js"></script>
    <script src="/ViewV5/JS/httpVueLoader.js"></script>
    <script type="text/javascript" src="/ViewV5/JS/jquery-1.11.2.min.js"></script>
    <script src="/ViewV5/JS/lodash.min.js"></script>
    <script src="/ViewV5/JS/layer/layer.js"></script>
    <script src="/ViewV5/JS/element/element.js"></script>
    <script src="/ViewV5/JS/element/pltable/index.js"></script>
    <script src="/ViewV5/JS/bijs.js?v=5"></script>


    <script>
        var app = new Vue({
            el: '#WORK',
            components: {
                'base-xq': httpVueLoader('/ViewV5/AppPage/QJJW/component/conxq.vue'),
            },
            data: {
                imPortData: [],
                tabfiledlist: [],
                ImportMsg: "",
                xq: ComFunJS.getQueryString('xq', '0'),
                cddata: [
                    //{ url: "/web_jxjh/web_jxjh_load.aspx", mc: "计划导入", img: "1", gnsm:"" },
                    { url: "/web_jxjh/jxjh_sr_new.aspx", mc: "计划录入", img: "2", gnsm: "" },
                    { url: "/web_jxjh/jxjh_sm_new.aspx", mc: "计划说明", img: "3", gnsm: "" },
                    { url: "/web_jxjh/jxjh_czsc.aspx", mc: "计划参照", img: "4", gnsm: "" }
                ],
                query: {
                    xq: { value: "" },

                },

            },
            methods: {
                tableRowClassName(row, rowIndex) {
                    if (row.row.导入状态) {
                        return 'warning-row';
                    } else {
                        return '';
                    }
                },
                init: function () {

                },
                jxfiled: function (jxdata) {
                    app.tabfiledlist = [];
                    _.forEach(_.keys(jxdata[0]), function (value) {
                        var fid = {
                            ColumnName: value,
                            ColumnType: "Str",
                            Dimension: "1",
                            Name: value,
                        }
                        if (_.findIndex(app.tabfiledlist, function (o) { return o.ColumnName == fid.ColumnName; }) == -1) {
                            app.tabfiledlist.push(fid);
                        }
                    });
                },//解析数据维度
                LoadUser: function () {
                    if (document.getElementById("upFile").files.length > 0) {
                        $(".tp-man").show();
                        app.imPortData = [];
                        app.ImportCount = 0;
                        var formData = new FormData();
                        formData.append("upFile", document.getElementById("upFile").files[0]);
                        formData.append("headrow", 0);
                        $.ajax({
                            url: "/API/VIEWAPI.ashx?Action=UPEXCEL",
                            type: "POST",
                            data: formData,
                            /**
                            *必须false才会自动加上正确的Content-Type
                            */
                            contentType: false,
                            /**
                            * 必须false才会避开jQuery对 formdata 的默认处理
                            * XMLHttpRequest会对 formdata 进行正确的处理
                            */
                            processData: false,
                            success: function (result) {
                                document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
                                $("#upFile").change(function () {
                                    app.LoadUser();
                                });
                                var r = $.parseJSON(result);
                                if (r.ErrorMsg == "") {
                                    //app.jxfiled(r.Result);
                                    for (var i = 0; i < r.Result.length; i++) {
                                        r.Result[i]["导入状态"] = "";
                                        r.Result[i]["hbbh"] = "";
                                        r.Result[i]["jsdm"] = "";
                                        r.Result[i]["bh"] = "";


                                    }
                                    app.imPortData = r.Result;
                                    if (app.imPortData.length > 0) {
                                        app.ImportCount = app.imPortData.length;

                                    } else {
                                        ComFunJS.winwarning('没有数据哦');
                                    }
                                }
                                else {
                                    ComFunJS.winwarning(r.ErrorMsg);
                                }
                            }
                        });
                    }
                    else {
                        ComFunJS.winwarning("请上传文件");
                    }
                },
                gomenu: function (item) {
                    top.addNewTab(item.url, item.mc, item.mc)
                },
                CheckData: function () {
                    app.ImportMsg = "";
                    $.getJSON("/api/Bll/ExeAction?Action=JXJH_CHECKRWDATA", { P1: JSON.stringify(app.imPortData) },
                        function (result) {
                            app.imPortData = result.Result;
                            var count = 0;
                            for (var i = 0; i < app.imPortData.length; i++) {
                                if (app.imPortData[i].导入状态) {
                                    count++;
                                }
                            }
                            if (count != 0) {
                                app.ImportMsg = "共计检查出" + count + "个错误";

                            }

                        }
                    )
                },
                DRData: function () {
                    for (var i = 0; i < app.imPortData.length; i++) {
                        if (app.imPortData[i].导入状态) {
                            alert('请先处理错误数据');
                            return;
                        }
                    }
                    this.$confirm('是否要导入任务落实数据?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        center: true
                    }).then(() => {
                        const loading = this.$loading({
                            lock: true,
                            text: 'Loading',
                            spinner: 'el-icon-loading',
                            background: 'rgba(0, 0, 0, 0.7)'
                        });
                        $.getJSON("/api/Bll/ExeAction?Action=JXJH_DRRWDATA", { P1: JSON.stringify(app.imPortData), xq: app.query.xq.value },
                            function (result) {
                                alert('导入成功');
                                loading.close();
                            }
                        )
                    }).catch(() => {
                        loading.close();
                        app.$message({
                            type: 'info',
                            message: '已取消发起操作'
                        });
                    });


                },
                UploadClick: function () {
                    $("#upFile").trigger("click");
                }

            },
            created() {

            },
            mounted: function () {
                var pro = this;
                pro.$nextTick(function () {

                })
            }

        })
    </script>
</body>
</html>